package lab02.test19;

import java.util.Scanner;

public class Test19 {
    //    19、 	编写一个程序，
//    实现字符串的大小写转换并倒序输出，
//    如输入为“HelloWord”，输出为“DROwOLLEh”。
    public static void main(String[] args) {
        System.out.println("请输入想要进行转换的字符串：");
        Scanner scanner = new Scanner(System.in);
        String string = scanner.next();
//        String[] result = new String[string.length()];
        StringBuffer stringBuffer = new StringBuffer();
//        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < string.length(); i++) {
            char tmp = string.charAt(i);
            if (tmp >= 'a' && tmp <= 'z') {
                tmp = (char) (tmp - 32);
                stringBuffer.append(tmp);
            } else if (tmp >= 'A' && tmp <= 'Z') {
                tmp = (char) (tmp + 32);
                stringBuffer.append(tmp);
            }
        }

        //stringBuffer.reverse()：此方法返回StringBuffer对象的颠倒顺序。
        System.out.println(stringBuffer.reverse());
    }
}
